package com.rxh.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rxh.pojo.core.CoreTradeRate;
import com.rxh.service.TradeRateService;
import com.rxh.util.UserInfoUtils;
import com.rxh.utils.UUID;

/**
 * 
 * @author xuzm
 * @date 20180312
 *
 */
@Controller
@RequestMapping("/tradeRate")
public class TradeRateController {
	
    @Autowired
    private TradeRateService tradeService;

    @RequestMapping("/getTradeRateInfo")
    @ResponseBody
    public Map<String,Object> getTradeRateInfo(@RequestBody Map<String, Object> paramMap) {
    	
    	return tradeService.getTradeRateInfo(paramMap);
       
    }
    
    @RequestMapping("/getTradeRateInit")
    @ResponseBody
    public Map<String,Object> getTradeRateInit() {
    	
    	return tradeService.getTradeRateInit();
       
    }
    
    
    /**
     *  保存数据
     * @param id
     * @return
     */
    @RequestMapping("/save")
    @ResponseBody
    public Map<String, Object> save(@RequestBody CoreTradeRate tradeRate) {
    	
    	tradeRate.setId(UUID.createKey("core_trade_rate"));
    	tradeRate.setCreator(UserInfoUtils.getName());
    	return tradeService.save(tradeRate);

    }
    
    
    
    /**
     *  更新数据
     * @param id
     * @return
     */
    @RequestMapping("/update")
    @ResponseBody
    public Map<String, Object> update(@RequestBody CoreTradeRate tradeRate) {
    	
    	tradeRate.setModifier(UserInfoUtils.getName());
    	return tradeService.update(tradeRate);
    	
    }
    
    
    /**
     * 批量删除
     * 
     * @param ids
     * @return
     */
    @RequestMapping("/batchDel")
    @ResponseBody
    public Map<String, Object> batchDel(@RequestBody Map<String, Object> paramMap) {
    	Map<String, Object> result = tradeService.deleteByParams(paramMap);
        return result;
    }

}
